package com.ml.mall.service.asyn;

import com.ml.mall.bean.res.admin.vo.AdminOverviewSalesByCategoryVO;
import com.ml.mall.bean.res.purchase.PurchaseVariantQueryPageRes;
import com.ml.mall.bean.res.purchase.vo.PurchaseSupplierVO;
import com.ml.mall.bean.res.purchase.vo.PurchaseVariantVO;
import com.ml.mall.bean.res.supplier.SupplierVariantQueryPageRes;
import com.ml.mall.bean.vo.DateValueVO;
import com.ml.mall.mapper.AnalyticsPurchaseMapper;
import com.ml.mall.mapper.AnalyticsSupplierMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.Future;

/**
 * Created by kyyang on 2021/6/8 22:32
 */
@Component
public class AnalyticsPurchaseServiceAsyn {


    @Autowired
    private AnalyticsPurchaseMapper analyticsPurchaseMapper;


    /**
     * @description: 按照卖家 top N
     * @author kyyang
     * @date 2021/7/4 12:46
     * @version 1.0
     */
    @Async
    public Future<List<PurchaseSupplierVO>> selectSalesBySupplierTopN(int topN, String timeBegin, String timeEnd, Long companyId) {
        List<PurchaseSupplierVO> list = analyticsPurchaseMapper.selectSalesBySupplierTopN(topN,timeBegin,timeEnd,companyId);
        return new AsyncResult<>(list);
    }

    /**
     * @description: 按照variant top N
     * @author kyyang
     * @date 2021/7/4 12:46
     * @version 1.0
     */
    @Async
    public Future<List<PurchaseVariantVO>> selectSalesByVariantTopN(int topN, String timeBegin, String timeEnd, Long companyId) {
        List<PurchaseVariantVO> list = analyticsPurchaseMapper.selectSalesByVariantTopN(topN,timeBegin,timeEnd,companyId);
        return new AsyncResult<>(list);
    }

    /**
     * @description: 分类 top N
     * @author kyyang
     * @date 2021/7/4 12:46
     * @version 1.0
     */
    @Async
    public Future<List<DateValueVO>> getPurchaseSpentQueryReportByCategoryTopN(int topN, String timeBegin, String timeEnd, Long companyId) {
        List<DateValueVO> list = analyticsPurchaseMapper.selectPurchaseSpentQueryReportByCategoryTopN(topN,timeBegin,timeEnd,companyId);
        return new AsyncResult<>(list);
    }

    /**
     * @description: 买家中 卖家 top N
     * @author kyyang
     * @date 2021/7/4 14:42
     * @version 1.0
     */
    @Async
    public Future<List<DateValueVO>> getPurchaseSupplierQueryReport(int topN, String timeBegin, String timeEnd, Long companyId) {
        List<DateValueVO> list = analyticsPurchaseMapper.selectPurchaseSupplierQueryReport(topN,timeBegin,timeEnd,companyId);
        return new AsyncResult<>(list);
    }

    /**
     * @description: 消费订单的卖家 分页查询 总记录数
     * @author kyyang
     * @date 2021/7/4 14:53
     * @version 1.0
     */
    @Async
    public Future<Integer> selectPurchaseSupplierQueryPageCount(String timeBegin, String timeEnd, int sortType, String supplierCode, Long companyId) {
        Integer count = analyticsPurchaseMapper.selectPurchaseSupplierQueryPageCount(timeBegin,timeEnd,supplierCode,companyId);
        return new AsyncResult<>(count);
    }

    /**
     * @description: 消费订单的卖家 分页查询 记录明细
     * @author kyyang
     * @date 2021/7/4 14:53
     * @version 1.0
     */
    @Async
    public Future<List<PurchaseSupplierVO>> selectPurchaseSupplierQueryPageList(String timeBegin, String timeEnd, int sortType, String supplierCode, int start, int end, Long companyId) {
        List<PurchaseSupplierVO> list = analyticsPurchaseMapper.selectPurchaseSupplierQueryPageList(timeBegin,timeEnd,sortType,supplierCode,start,end,companyId);
        return new AsyncResult<>(list);
    }



    /**
     * @description: 分页查询买家消费产品 总记录数
     * @author kyyang
     * @date 2021/7/4 15:08
     * @version 1.0
     */
    @Async
    public Future<Integer> selectPurchaseVariantQueryPageCount(String timeBegin, String timeEnd, String supplierCode, Long companyId, String categoryId, String variantName) {
        Integer count = analyticsPurchaseMapper.selectPurchaseVariantQueryPageCount(timeBegin,timeEnd,supplierCode,companyId,categoryId,variantName);
        return new AsyncResult<>(count);
    }

    /**
     * @description: 分页查询买家消费产品 总记录明细
     * @author kyyang
     * @date 2021/7/4 15:08
     * @version 1.0
     */
    @Async
    public Future<List<PurchaseVariantQueryPageRes>> selectPurchaseVariantQueryPageList(String timeBegin, String timeEnd, int sortType, String supplierCode, int start, int end, Long companyId, String categoryId, String variantName) {
        List<PurchaseVariantQueryPageRes> list = analyticsPurchaseMapper.selectPurchaseVariantQueryPageList(timeBegin,timeEnd,sortType,supplierCode,start,end,companyId,categoryId,variantName);
        return new AsyncResult<>(list);
    }

}
